﻿using Microsoft.UI.Windowing;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using WinRT.Interop;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace Rmac.WinUI;

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : MauiWinUIApplication
{
	/// <summary>
	/// Initializes the singleton application object.  This is the first line of authored code
	/// executed, and as such is the logical equivalent of main() or WinMain().
	/// </summary>
	public App()
	{
		this.InitializeComponent();
	}

    /// <summary>
    /// 设置界面宽高
    /// </summary>
    /// <param name="args"></param>
    protected override void OnLaunched(LaunchActivatedEventArgs args)
    {
        base.OnLaunched(args);
        var currentWindow = Application.Windows[0].Handler.PlatformView;
        IntPtr _windowHandle = WindowNative.GetWindowHandle(currentWindow);
        var windowId = Win32Interop.GetWindowIdFromWindow(_windowHandle);
        AppWindow appWindow = AppWindow.GetFromWindowId(windowId);

        OverlappedPresenter overlappedPresenter = appWindow.Presenter as OverlappedPresenter;
        overlappedPresenter.SetBorderAndTitleBar(true, true);
        overlappedPresenter.Maximize();
    }
    protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}

